package com.zlb.app.common.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.zlb.app.common.injector.SqlInjectorPlus;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @Desc MyBatisPlus配置类
 * @Author zWX1367238
 * @Date 2024-08-14 14:43:56
 **/
@EnableTransactionManagement
@Configuration
public class MyBatisPlusConfig {

    // 配置分页器
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.GAUSS));
        return interceptor;
    }

    // 增强sql注入的Bean
    @Bean
    public SqlInjectorPlus sqlInjectorPlus() {
        return new SqlInjectorPlus();
    }

}
